package com.yzf.demo.demo.DesignPattren.PrototypePattern.Cloneable;

import java.util.List;

/**
 * Created by 于占峰 on 2020/3/16/016.
 * 实现Cloneable接口的clone
 */
public class DemoBean implements Cloneable {
    private String name;
    private Integer age;
    //爱好
    private List<String> hobbys;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public List<String> getHobbys() {
        return hobbys;
    }

    public void setHobbys(List<String> hobbys) {
        this.hobbys = hobbys;
    }

    @Override
    public DemoBean clone() {
        try {
            return (DemoBean) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public String toString() {
        return "DemoBean{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", hobbys=" + hobbys +
                '}';
    }
}
